package com.waimai.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

//设置自动添加修改人，修改时间的类Mybatis plus_元数据
@Component
public class MybatisPlusMate implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
     metaObject.setValue("createTime", LocalDateTime.now());
     metaObject.setValue("updateTime", LocalDateTime.now());
     metaObject.setValue("createUser", new Long(1));
     metaObject.setValue("updateUser",new Long(1));
    }


    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("updateUser", new Long(1));
    }
}
